#ifndef _FOREACH_H_
#define _FOREACH_H_
/*
#include <deque>
#include <list>
#include <vector>
class Range
{

    public:
    class iterator;
	Range(int value)
	:mValue(value)
	{
	}
	iterator begin() const
	{
		return iterator(0);
	}
	iterator end() const
	{
		return mValue;
	}
	bool empty() const
	{
	    return mValue.mValue <= 0;
	}
	class iterator
	{
	    public:
	    iterator(int value)
	    :mValue(value)
	    {
	    }
	    int mValue;
	    bool operator==(const iterator& a) const
	    {
	        return mValue == a.mValue;
	    }
	    bool operator!=(const iterator& a) const
	    {
	        return mValue != a.mValue;
	    }
	    void operator=(const iterator& a)
	    {
	        mValue = a.mValue;
	    }
	    void operator++()
	    {
	        ++mValue;
	    }
	    int operator*() const
	    {
	       return mValue;
	    }
	};
	iterator mValue;
	typedef const iterator const_iterator;
};*/


template <typename T>
class QForeachContainer {
public:
    inline QForeachContainer(const T& t) : c(t), brk(0), i(c.begin()), e(c.end()) { }
    const T c;
    int brk;
    typename T::const_iterator i, e;
};

#define qforeach(variable, container)                                \
for (QForeachContainer<__typeof__(container)> _container_(container); \
     !_container_.brk && _container_.i != _container_.e;              \
     __extension__  ({ ++_container_.brk; ++_container_.i; }))                       \
    for (variable = *_container_.i;; __extension__ ({--_container_.brk; break;}))

#define foreach(__VAR__, __LIST__) \
if(!__LIST__.empty())\
for(auto __it__ = __LIST__.begin();__VAR__ = *__it__, __it__!=__LIST__.end();++__it__)


#define foreach2(__VAR__, __LIST__) \
typedef typeof(__LIST__) __LISTT__; \
__LISTT__::iterator __it__ = __LIST__.begin(); \
__LISTT__::const_iterator __ite__ = __LIST__.end(); \
if(!__LIST__.empty())\
for(;__VAR__ = *__it__, __it__!=__ite__;++__it__)

/*
#define for_range(__VALUE__, __END__)\
for(;__VALUE__<__END__;++__VALUE__)
*/

#endif



